﻿Public Class Manager
    Private Sub New()
    End Sub

    Public Shared Function GenerateForMovie(ByVal imdbMoviePageUrl As Uri) As Entities.OpenMediaInfo.OpenMediaInfo
        Return GenerateForMovie(imdbMoviePageUrl, Nothing)
    End Function

    Public Shared Function GenerateForMovie(ByVal imdbMoviePageUrl As Uri, ByVal files() As String) As Entities.OpenMediaInfo.OpenMediaInfo
        Dim clsRet As New Entities.OpenMediaInfo.OpenMediaInfo
        clsRet.Version = 2
        clsRet.Feature = IMDB.Manager.GetMovieInfo(imdbMoviePageUrl)

        Dim clsStreamInfo As Entities.OpenMediaInfo.StreamInfo = Nothing
        If files IsNot Nothing AndAlso files.Length > 0 Then clsStreamInfo = MediaInfoDll.Manager.GetStreamInfo(files)

        If clsStreamInfo IsNot Nothing Then
            clsRet.Streams = New Generic.List(Of Entities.OpenMediaInfo.StreamInfo)
            clsRet.Streams.Add(clsStreamInfo)
        End If
        Return clsRet
    End Function

    Public Shared Function GenerateForMovie(ByVal files() As String) As Entities.OpenMediaInfo.OpenMediaInfo
        Dim clsRet As New Entities.OpenMediaInfo.OpenMediaInfo
        clsRet.Version = 2

        Dim clsStreamInfo As Entities.OpenMediaInfo.StreamInfo = MediaInfoDll.Manager.GetStreamInfo(files)
        If clsStreamInfo IsNot Nothing Then
            clsRet.Streams = New Generic.List(Of Entities.OpenMediaInfo.StreamInfo)
            clsRet.Streams.Add(clsStreamInfo)
        End If
        Return clsRet
    End Function

    Public Shared Function GetSuggestedOMXFileName(ByVal item As Entities.SharedItem, ByVal files() As String) As String
        Dim strDir As String = item.Directory
        Dim strFilename As String
        Select Case item.GroupMode
            Case Entities.GroupMode.GroupIdenticalExtensionlessFilenames
                strFilename = item.Name & ".omx"
            Case Entities.GroupMode.GroupSubDirectories
                strFilename = item.Name & ".omx"
            Case Else
                strFilename = IO.Path.GetFileNameWithoutExtension(files(0)) & ".omx"
        End Select
        Return IO.Path.Combine(strDir, strFilename)
    End Function

End Class
